package com.amazon.trietree.io;

import com.amazon.trietree.fingerprint.FingerPrint;
import com.amazon.trietree.fingerprint.FingerPrintFileContainer;

/**
 * Created with IntelliJ IDEA.
 * User: Tylaar
 * Date: 10/30/12
 * Time: 5:11 PM
 * Company: Amazon.com
 */
public class FingerPrintFileDecoder {

    private static final int pieceNumPos = 2;

    public static FingerPrintFileContainer decodeLine(String line){
        String[] pieces = line.split("\t");

        int counts = Integer.parseInt(pieces[pieceNumPos]);
        System.out.println("fingerPrint counts:" + counts);
        FingerPrintFileContainer container = new FingerPrintFileContainer(pieces[0], counts);
        for(int i = 3 ; i < pieces.length ; i += 2){
            container.AddFingerPrint(new FingerPrint(pieces[i], Integer.parseInt(pieces[i+1])));
        }
        return container;

    }
}
